#!/bin/sh

#  This file is part of Elixir, a source code cross-referencer.
#
#  Copyright (C) 2019--2020 Michael Opdenacker and contributors
#
#  Elixir is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Affero General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  Elixir is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Affero General Public License for more details.
#
#  You should have received a copy of the GNU Affero General Public License
#  along with Elixir.  If not, see <http://www.gnu.org/licenses/>.

export ELIXIR_INSTALL=$(dirname $(dirname $(readlink -f "$0")))
. $ELIXIR_INSTALL/utils/common.sh

if [ -z "$LXR_PROJ_DIR" ]; then
    echo "ERROR: LXR_PROJ_DIR environment variable not set"
    exit 1
fi

for dir_name in $LXR_PROJ_DIR/*; do
    echo "Processing project $dir_name ..."
    export LXR_DATA_DIR=$dir_name/data
    export LXR_REPO_DIR=$dir_name/repo

    cd $LXR_REPO_DIR
    git fetch --all --tags

    cd $ELIXIR_INSTALL
    ./update.py $ELIXIR_THREADS
done
